#include<stdio.h>

int main()
{
	int y, m, d;
	int w;
	scanf_s("%d%d%d", &y, &m, &d);
	if (m == 1 || m == 2) {
		m = m + 12;
		y = y - 1;
		w = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7;
		printf("%d\n", w);
	}
	else if (m == 3 || m == 4 || m == 5 || m == 6 || m == 7 || m == 8 || m == 9 || m == 10 || m == 11 || m == 12) {
		w = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7;
		printf("%d\n", w);
	}
	return 0;
}
